package com.ushine.web.base.model.system;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ushine.web.base.model.base.BaseBO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Author: yls
 * @Date: 2021/3/3 9:33
 * @Description: 角色表
 * @Version 1.0
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@ApiModel(description = "角色表")
@Table(name = "t_system_role")
@org.hibernate.annotations.Table(appliesTo = "t_system_role", comment = "角色表")
@TableName(value = "t_system_role")
public class RoleDO extends BaseBO implements Serializable {
    /**
     * 编号
     * // 解决前台js接收雪花id精度丢失问题
     * JsonFormat(shape = JsonFormat.Shape.STRING)
     */
    @Id
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty("编号")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Column(name = "id", columnDefinition = "bigint comment '编号'")
    private Long id;

    /**
     * 角色名称
     */
    @ApiModelProperty("角色名称")
    @Column(name = "name", columnDefinition = "varchar(32) comment '角色名称'")
    @NotBlank(message = "角色名称不能为空")
    @Length(max = 255, message = "角色名称最大长度为：255")
    private String name;

    /**
     * 备注
     */
    @ApiModelProperty("备注")
    @Column(name = "remarks", columnDefinition = "varchar(255) comment '备注'")
    @Length(max = 255, message = "备注最大长度为：255")
    private String remarks;

    /**
     * 逻辑删除
     * TableField => select:false (在查询的时候排除该字段)
     */
    @TableLogic
    @TableField(value = "is_deleted", fill = FieldFill.INSERT, select = false)
    @ApiModelProperty(value = "逻辑删除", example = "0")
    @Column(name = "is_deleted", columnDefinition = "datetime comment '删除标记=> 不为null：已删除，为空：未删除'")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime deleted;

}
